import Api from '@/service/api/api';
import { getServiceBaseURL } from '@/utils/service';
import { request } from '../request';

const isHttpProxy = import.meta.env.DEV && import.meta.env.VITE_HTTP_PROXY === 'Y';
const { baseURL, otherBaseURL } = getServiceBaseURL(import.meta.env, isHttpProxy);

/**
 * 获取文档标签
 *
 * @param params
 */
export function getDocumentLabelAction(params: any) {
  return request<any>({
    baseURL: otherBaseURL.writeLabel,
    url: Api.GetLabel,
    method: 'post',
    data: params
  });
}

/**
 * 获取模版文件列表
 *
 * @param params
 */
export function getDocumentTemplateAction(params: any) {
  return request<any>({
    baseURL: otherBaseURL.writeLabel,
    url: Api.GetTemplate,
    method: 'post',
    data: params
  });
}

/**
 * 获取标签树
 *
 * @param params
 */
export function getLabelTreeAction(params: any) {
  return request<any>({
    url: Api.LabelTree,
    method: 'get',
    params
  });
}

/**
 * 查询解析内容
 *
 * @param params
 */
export function getAnalysisListAction(params: any) {
  return request<any>({
    url: Api.AnalysisList,
    method: 'get',
    params
  });
}

/**
 * 新增内容标签绑定
 *
 * @param params
 */
export function labelBindingInsertAction(params: any) {
  return request<any>({
    url: Api.LabelBindInsert,
    method: 'post',
    data: params
  });
}

/**
 * 新增自选内容标签绑定
 *
 * @param params
 */
export function labelBindingCustomizeInsertAction(params: any) {
  return request<any>({
    url: Api.UpdateAnalysisData,
    method: 'post',
    data: params
  });
}

/**
 * 更新内容标签绑定
 *
 * @param params
 */
export function labelBindingUpdateAction(params: any) {
  return request<any>({
    url: Api.LabelBindUpdate,
    method: 'post',
    data: params
  });
}

/**
 * 删除内容标签绑定
 *
 * @param params
 */
export function labelBindingDeleteAction(params: any) {
  return request<any>({
    url: Api.LabelBindDelete,
    method: 'get',
    params
  });
}

/**
 * 保存解析内容
 *
 * @param params
 */
export function analysisInsertAction(params: any) {
  return request<any>({
    url: Api.AnalysisInsert,
    method: 'post',
    data: params
  });
}

/**
 * 新增解析记录
 *
 * @param params
 */
export function analysisInsertLogAction(params: any) {
  return request<any>({
    url: Api.InsertLog,
    method: 'post',
    data: params
  });
}

/**
 * 获取与该任务记录相关的所有自定义标签
 *
 * @param params
 */
export function getCustomLabelListAction(params: any) {
  return request<any>({
    url: Api.CustomLabelList,
    method: 'get',
    params
  });
}

/**
 * 保存慧眼识标模版填充的文件
 *
 * @param params
 */
export function analysisInsertFileAction(params: any) {
  return request<any>({
    url: Api.InsertFile,
    method: 'post',
    data: params
  });
}

/**
 * 获取慧眼识标保存的模版填充的文件
 *
 * @param params
 */
export function getTemplateFileAction(params: any) {
  return request<any>({
    url: Api.TemplateFile,
    method: 'get',
    params
  });
}

/**
 * 慧眼识标解析记录
 *
 * @param params
 */
export function getAnalysisLogAction(params: any) {
  return request<any>({
    url: Api.AnalysisLog,
    method: 'get',
    params
  });
}

/**
 * 更新慧眼识标模版填充的文件
 *
 * @param params
 */
export function analysisUpdateFileAction(params: any) {
  return request<any>({
    url: Api.AnalysisUpdateFile,
    method: 'post',
    data: params
  });
}
